package de.kieselbach.javafx.builder.factory

import javafx.scene.text.Text

/*
 * Copyright 2012 by procar informatik AG,
 * Eschenweg 7, 64331 Weiterstadt, Germany
 * All rights reserved.
 */
class TextBuilderFactory extends AbstractBuilderFactory {

    @Override
    String getName() {

        return 'text'
    }

    @Override
    Class getNodeClass() {
        return Text.class
    }

    @Override
    void nodeCompleted(Object parent, Object child) {

        throw new UnsupportedOperationException("You cannot add child nodes to a button!");
    }

    @Override
    def createNode(Object name, Map attributes, Object value) {

        def text = new Text()

        if(value) {
            text.text = value
        }

        if(attributes != null) {
            attributes.each() {key, val ->
                text[key] = val
            }
        }

        text
    }
}
